All Questions
13 questions
1vote
2answers
290views
Optimize printing massive strings to System.out with respect to time
I need to cut the time it takes to print a large string by ~50%. I went from using s1 + s2 to using StringBuilder, and instead ...
0votes
1answer
692views
Java exercise: String processing and type conversion
The exercise is from a Java-course in which I'm enrolled. The classes Book and APIResponseParser were provided by the instructor. For Book I had to add just a few getter- and setter-methods. For ...
0votes
2answers
2kviews
Data structure to count occurrences of words
I have some code for a assignment where the main marks are awarded based on efficiency. The program uses a given wordgenerator which generates random words and adds them to a user-made data structure. ...
2votes
1answer
4kviews
Case-insensitive replacement of "java" with "JAVA" using String.substring()
Assignment: Create a program Substitute that gets a sentence from the user and replaces every occurrence of the word java (uppercase, lowercase, or a combination) with JAVA. You may not change the ...
1vote
1answer
1kviews
Find all occurrences of the word "the" without using regex
I have an assignment to find all occurrences of the word "the" without using regex: Use the indexOf method to do this. The word "the" could also appear in a ...
1vote
4answers
97views
Form a [email protected] address, eliminating diacritics from a name
I'm an amateur programmer who just started learning programming, my school gave me an assignment to create code that reads a surname and lastname from an input dialog box and then to edit those name ...
-2votes
2answers
673views
Manipulating strings and character positions
Write a program that manipulates two strings. The program inputs two strings (string1 and string2) and a character (...
5votes
4answers
16kviews
Word Guessing Game
I'm trying to learn Java (albeit rather slowly). I'm in a computer science class at my highschool and I've written this little bit of code for a project. Basically it is a word guessing game where if ...
4votes
3answers
2kviews
Sorting strings in a one dimensional array
What are the better solutions possible? I have a character array with different strings. There is a max size for the strings. In case a string is smaller than max size remaining places are filled ...
11votes
8answers
18kviews
Return a string without the first two characters
I'm new to Java and am trying to solve a scenario. Even though I've succeeded and it works, I've just wondered if there was a more practical way of doing this task. Is there a quicker or more ...
0votes
1answer
121views
Processing a string from the console
How can I make this program run faster? On enter, I have a string from the console. For example: 1 1 7 3 2 0 0 4 5 5 6 2 1 On exit, it will be ...
2votes
1answer
218views
High School Java Class: Pong Project External Reviewer
It would be a huge help if you could tell me ways to make my code run smoother and if I could add more code to my program to make my program more unique. Panelball class: ...
8votes
3answers
20kviews
Replace multiple occurrences of a character
I try to replace multiple occurrences of a character with a single character. Input: hhiii!!! hooowww aaareee yyyooou??? Output: hi! how are you? ...